<?php

/**
 * @deprecated Pouzi triedu Db_DbTable_*
 * 
 * Student
 *  
 * @author Radovan Dvorsky
 * @version 20100107
 */

require_once 'Zend/Db/Table/Abstract.php';

class Db_Student extends Zend_Db_Table_Abstract {

	/**
	 * Database name
	 * @var string
	 */
	protected $_dbName; 
	
	/**
	 * Table name
	 * @var string 
	 */
	protected $_name = 'Student';
	
	/**
	 * Primary key
	 * @var string
	 */	
	protected $_primary = 'ID_st';
	
	/**
	 * Mena zavislich tabuliek
	 * @var array
	 */
	protected $_dependentTables = array('Db_Result','Db_HarmonogramUchazeci','Db_StutentHasTridy');
	
	public function init(){
		
		/*
		 * Nastav adapter pre druhu databazu
		 */
		$this->_setAdapter(Zend_Registry::get('db2'));
		$config = Zend_Registry::get('config');
		
		/*
		 * Inicializuj premenu s menom druhej databaze
		 */
		$this->_dbName = $config->database2->params->dbname;
	}
	
	
	/**
	 * Vrati z databaze vsetkych studentov vratane mena skupiny, do ktorej
	 * patria
	 * 
	 * TODO treba pridať podmienku, ktorú bude selectovať len studentov, ktorych treba
	 * vyskúšať
	 * 
	 * @return Zend_Db_Table_Rowset
	 */
	public function fetchAllStudentsWithGroups(){
		$select = $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
		$select->setIntegrityCheck(false)			
		->join('Student_T_Tridy','Student.ID_st = Student_T_Tridy.ID_st')
		->join('T_Tridy','Student_T_Tridy.ID_tr = T_Tridy.ID_tr');			
		
		return $this->fetchAll($select);		
	}
}